package com.hxy.provider;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 消息提供者
 */
@Component
public class Sender {
    @Autowired
    private AmqpTemplate template;

    @Value("${mq.queue.name}")
    private String queueName;

    /**
     * 发送消息的方法
     */
    public void send(String msg) {
        // 队列名称，消息内容
        template.convertAndSend(queueName,msg);
    }
}
